from django.contrib.auth.models import Permission, Group
from django.contrib.contenttypes.models import ContentType
from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet

from apps.meiduo_admin.serializers.permission import PermissionModelSerializer, ContentTypeModelSerializer, \
    GroupSerializer
from apps.meiduo_admin.utils import PageNum


# 权限
class PermissionModelViewSet(ModelViewSet):
    queryset = Permission.objects.all()

    serializer_class = PermissionModelSerializer

    # 添加分页类
    pagination_class = PageNum


# 权限类型
class ContentTypeModelView(ListAPIView):
    queryset = ContentType.objects.all()

    serializer_class = ContentTypeModelSerializer


# 组的视图
class GroupView(ModelViewSet):

    serializer_class = GroupSerializer

    queryset = Group.objects.all()

    pagination_class = PageNum

class GroupSimpleAPIView(ListAPIView):
    queryset =  Permission.objects.all()

    serializer_class = PermissionModelSerializer
